
exports.SysTree = new Class
  initPrn_id: ->
    t = this
    o = t.options
    elt = o.ele
    prn_id = elt.getE "[h:iez=prn_id]"
    cb_input = elt.getE ".combotree_input"
    cb_tree = prn_id.getE ".combotree_tree"
    cb_treeWg = cb_tree.wg()
    setVal = cb_treeWg.setVal
    cb_treeWg.setVal = (id)-> yield setVal.apply this,[{id:id}]
    getVal = cb_treeWg.getVal
    cb_treeWg.getVal = ->
      eny = yield getVal.apply this,arguments
      return 0 if eny is null
      if eny
        oldVal = this.getOldVal()
        return if oldVal is eny.id
        return eny.id
      return
    cb_treeWg.treAllPrnId = (eny)->
      return [] if !eny
      rltSet = yield o.thisSrv.ajax "treAllPrnId",[eny.id]
      rltSet
    cb_treeWg.getLbl = (tree_li)->
      eny = tree_li.retrieve "eny"
      lbl = eny and eny.lbl or ""
      lbl
    cb_treeWg.isLeaf = (tree_li)->
      eny = tree_li.retrieve "eny"
      return eny.is_leaf if eny
      false
    getChildren = cb_treeWg.getChildren
    cb_treeWg.getChildren = (tree_li,hLvl)->
      liElArr = yield getChildren.apply this,arguments
      rltSet = []
      if hLvl is 0
        rltSet = yield o.thisSrv.ajax "treeRoot"
      else
        eny = tree_li.retrieve "eny"
        rltSet = yield o.thisSrv.ajax "treeCld",[eny.id]
      for eny in rltSet
        li = new Element "div"
        li.store "eny",eny
        liElArr.push li
      liElArr
    yield cb_treeWg.dataTree()
    return